<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/26
  Time: 22:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java"  pageEncoding="UTF-8" %>

<c:set var="p" value="${pageBean}"/>
<%--页码处理--%>
<c:choose>
    <%--当显示页码时,总页码<=10时，全部显示--%>
    <c:when test="${p.totalPage<=10}">
        <c:set var="begin" value="1"/>
        <c:set var="end" value="${p.totalPage}"/>
    </c:when>
    <%--当总页码>10时,只显示10页--%>
    <c:otherwise>
        <c:set var="begin" value="${p.pageNo-5}"/>
        <c:set var="end" value="${p.pageNo+4}"/>
        <%--当前页-5后的begin<1时：begin=1, end=10--%>
        <c:if test="${begin<1}">
            <c:set var="begin" value="1"/>
            <c:set var="end" value="10"/>
        </c:if>
        <%--当前页+4后的end>总页数时:begin=总页数-9,end=总页数--%>
        <c:if test="${end>p.totalPage}">
            <c:set var="begin" value="${p.totalPage-9}"/>
            <c:set var="end" value="${p.totalPage}"/>
        </c:if>
    </c:otherwise>
</c:choose>

<div class="container">
    <div class="row clearfix">
        <div class="col-md-2 column">
        </div>
        <div class="col-md-3 column" style="text-align: right">
            <ul class="pagination">
                <li style="line-height: 35px">
                    第${p.pageNo}页/共${p.totalPage}页
                </li>
            </ul>

        </div>
        <div class="col-md-7 column" style="text-align: left">

            <ul class="pagination">

                <c:choose>
                    <c:when test="${p.pageNo==1}">
                        <li class="disabled">
                            <a href="${pageContext.request.contextPath}/findPage?page=1">首页</a>
                        </li>
                    </c:when>
                    <c:otherwise>
                        <li><a href="${pageContext.request.contextPath}/findPage?page=1">首页</a></li>
                    </c:otherwise>
                </c:choose>


                <%--上一页--%>
                <c:if test="${p.pageNo>1}">
                    <li class="">
                        <a href="${pageContext.request.contextPath}/findPage?page=${p.pageNo-1}"
                           aria-label="Previous">
                            <span aria-hidden="true">上一页</span></a>
                    </li>
                </c:if>

                <%--<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>--%>

                <%--当前页面为最后一页时不显示下一页--%>
                <c:if test="${p.pageNo<p.totalPage}">
                    <li>
                        <a href="${pageContext.request.contextPath}/findPage?page=${p.pageNo+1}"
                           aria-label="Next">
                            <span aria-hidden="true">下一页</span>
                        </a>
                    </li>
                </c:if>
                <c:choose>
                    <c:when test="${p.pageNo==p.totalPage}">
                        <li class="disabled">
                            <a href="${pageContext.request.contextPath}/findPage?page=${p.totalPage}">尾页</a>
                        </li>
                    </c:when>
                    <c:otherwise>
                        <li><a href="${pageContext.request.contextPath}/findPage?page=${p.totalPage}">尾页</a></li>
                    </c:otherwise>
                </c:choose>
            </ul>
        </div>
    </div>
</div>
